/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package suministros.ejb30.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Luis_Angel
 */
@Entity
@Table(name = "elemento_costo")
@NamedQueries({
    @NamedQuery(name = "ElementoCosto.findAll", query = "SELECT e FROM ElementoCosto e"),
    @NamedQuery(name = "ElementoCosto.findByIdElementoCosto", query = "SELECT e FROM ElementoCosto e WHERE e.idElementoCosto = :idElementoCosto"),
    @NamedQuery(name = "ElementoCosto.findByDescElemento", query = "SELECT e FROM ElementoCosto e WHERE e.descElemento = :descElemento"),
    @NamedQuery(name = "ElementoCosto.findByVerReporteCostoDiario", query = "SELECT e FROM ElementoCosto e WHERE e.verReporteCostoDiario = :verReporteCostoDiario"),
    @NamedQuery(name = "ElementoCosto.findByVerDetalleContable", query = "SELECT e FROM ElementoCosto e WHERE e.verDetalleContable = :verDetalleContable")})
public class ElementoCosto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_elemento_costo")
    private String idElementoCosto;
    @Column(name = "desc_elemento")
    private String descElemento;
    @Basic(optional = false)
    @Column(name = "ver_reporte_costo_diario")
    private boolean verReporteCostoDiario;
    @Basic(optional = false)
    @Column(name = "ver_detalle_contable")
    private boolean verDetalleContable;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idElementoCosto")
    private List<CosteoDiario> costeoDiarioList;
    @OneToMany(mappedBy = "idElementoPadre")
    private List<ElementoCosto> elementoCostoList;
    @JoinColumn(name = "id_elemento_padre", referencedColumnName = "id_elemento_costo")
    @ManyToOne
    private ElementoCosto idElementoPadre;

    public ElementoCosto() {
    }

    public ElementoCosto(String idElementoCosto) {
        this.idElementoCosto = idElementoCosto;
    }

    public ElementoCosto(String idElementoCosto, boolean verReporteCostoDiario, boolean verDetalleContable) {
        this.idElementoCosto = idElementoCosto;
        this.verReporteCostoDiario = verReporteCostoDiario;
        this.verDetalleContable = verDetalleContable;
    }

    public String getIdElementoCosto() {
        return idElementoCosto;
    }

    public void setIdElementoCosto(String idElementoCosto) {
        this.idElementoCosto = idElementoCosto;
    }

    public String getDescElemento() {
        return descElemento;
    }

    public void setDescElemento(String descElemento) {
        this.descElemento = descElemento;
    }

    public boolean getVerReporteCostoDiario() {
        return verReporteCostoDiario;
    }

    public void setVerReporteCostoDiario(boolean verReporteCostoDiario) {
        this.verReporteCostoDiario = verReporteCostoDiario;
    }

    public boolean getVerDetalleContable() {
        return verDetalleContable;
    }

    public void setVerDetalleContable(boolean verDetalleContable) {
        this.verDetalleContable = verDetalleContable;
    }

    public List<CosteoDiario> getCosteoDiarioList() {
        return costeoDiarioList;
    }

    public void setCosteoDiarioList(List<CosteoDiario> costeoDiarioList) {
        this.costeoDiarioList = costeoDiarioList;
    }

    public List<ElementoCosto> getElementoCostoList() {
        return elementoCostoList;
    }

    public void setElementoCostoList(List<ElementoCosto> elementoCostoList) {
        this.elementoCostoList = elementoCostoList;
    }

    public ElementoCosto getIdElementoPadre() {
        return idElementoPadre;
    }

    public void setIdElementoPadre(ElementoCosto idElementoPadre) {
        this.idElementoPadre = idElementoPadre;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idElementoCosto != null ? idElementoCosto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ElementoCosto)) {
            return false;
        }
        ElementoCosto other = (ElementoCosto) object;
        if ((this.idElementoCosto == null && other.idElementoCosto != null) || (this.idElementoCosto != null && !this.idElementoCosto.equals(other.idElementoCosto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getDescElemento();
    }

}
